Public Class FormLyric
    Private CorrectUrl As String = String.Empty
    Sub loadLyric(ByVal checksum As String, ByVal id As Integer)
        Try
            WebBrowserLyric.Visible = False
            TextBoxLyric.Visible = True
            Dim clapi As New ChartlyricsApi.apiv1()
            Dim cllr As ChartlyricsApi.GetLyricResult = clapi.GetLyric(id, checksum)
            Dim lyric As String = cllr.Lyric.Replace(Chr(13), vbNewLine)
            lyric = lyric.Replace(Chr(10), vbNewLine)
            'lyric = lyric.Replace(Chr(13), "*13*")
            TextBoxLyric.Text = lyric
            TextBoxArtist.Text = cllr.LyricArtist
            TextBoxSong.Text = cllr.LyricSong
            CorrectUrl = cllr.LyricCorrectUrl
            Me.Text = cllr.LyricArtist & " " & cllr.LyricSong
            If cllr.LyricCovertArtUrl.Length > 0 Then
                Dim coverUrl As String = cllr.LyricCovertArtUrl                
                PictureBoxCover.Image = New System.Drawing.Bitmap(New IO.MemoryStream(New System.Net.WebClient().DownloadData(coverUrl)))
            End If
            Me.Activate()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub

    Private Sub Correct_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Correct.Click
        Try
            If CorrectUrl.Length > 0 Then
                WebBrowserLyric.Visible = True
                TextBoxLyric.Visible = False
                WebBrowserLyric.Url = New System.Uri(CorrectUrl)
                WebBrowserLyric.Refresh()
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Private Sub ButtonLyric_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonLyric.Click
        Try
            WebBrowserLyric.Stop()
            WebBrowserLyric.Visible = False
            TextBoxLyric.Visible = True
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
    Sub addLyric(ByVal url As String, ByVal artist As String, ByVal song As String)
        Try
            TextBoxArtist.Text = artist
            TextBoxSong.Text = song
            CorrectUrl = url
            Me.Text = artist & " " & song
            WebBrowserLyric.Visible = True
            TextBoxLyric.Visible = False
            WebBrowserLyric.Url = New System.Uri(url)
            WebBrowserLyric.Refresh()
        Catch ex As Exception
            Throw ex
        End Try
    End Sub
End Class
